<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>强制刷新当前页面</title>
  </head>
  <body>
    <button>点击强制刷新页面</button>
    <div id="night">
      <span>5656</span>
    </div>
    <script>
      document.querySelector("button").onclick = function () {
        //   两种方式强制刷新
        location.reload();
        history.go(0);
        //在vue组件中是使用this.$forceUpdate()方法
        //在react组件中是使用this.forceUpdate()方法
      };
      //onload事件会在页面加载完成的时候触发，
      window.onload = function () {
        console.log("---------页面被加载了---");
      };
      let night = document.querySelector("#night");
      console.log(night.innerHTML);
    </script>
  </body>
</html>
